package com.example.educationblockchain.model;

import com.baomidou.mybatisplus.annotation.TableName;

import java.util.Objects;

@TableName(value = "Block")
public class Block {
    private long _index;

    private String _hash;

    private String previousHash;

    private long _timestamp;

    private String _name;

    private String _class;

    private String number;

    private String C4;//小文件块

    private String sk;//AES密钥

    private String pk;//ECC密钥

    public Block(int index, String hash, String previousHash, long timestamp, String name, String _class, String number, String c4, String sk, String pk) {
        this._index = index;
        this._hash = hash;
        this.previousHash = previousHash;
        this._timestamp = timestamp;
        this._name = name;
        this._class = _class;
        this.number = number;
        C4 = c4;
        this.sk = sk;
        this.pk = pk;
    }

    public Block() {
    }

    public long getIndex() {
        return _index;
    }

    public void setIndex(long index) {
        this._index = index;
    }

    public String getHash() {
        return _hash;
    }

    public void setHash(String hash) {
        this._hash = hash;
    }

    public String getPreviousHash() {
        return previousHash;
    }

    public void setPreviousHash(String previousHash) {
        this.previousHash = previousHash;
    }

    public long getTimestamp() {
        return _timestamp;
    }

    public void setTimestamp(long timestamp) {
        this._timestamp = timestamp;
    }

    public String getName() {
        return _name;
    }

    public void setName(String name) {
        this._name = name;
    }

    public String get_class() {
        return _class;
    }

    public void set_class(String _class) {
        this._class = _class;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public String getC4() {
        return C4;
    }

    public void setC4(String c4) {
        C4 = c4;
    }

    public String getSk() {
        return sk;
    }

    public void setSk(String sk) {
        this.sk = sk;
    }

    public String getPk() {
        return pk;
    }

    public void setPk(String pk) {
        this.pk = pk;
    }



    @Override
    public String toString() {
        return "Block{" +
                "index=" + _index +
                ", hash='" + _hash + '\'' +
                ", previousHash='" + previousHash + '\'' +
                ", timestamp=" + _timestamp +
                ", name='" + _name + '\'' +
                ", _class='" + _class + '\'' +
                ", number='" + number + '\'' +
                ", C4='" + C4 + '\'' +
                ", sk='" + sk + '\'' +
                ", pk='" + pk + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Block block = (Block) o;
        return _index == block._index &&
                _timestamp == block._timestamp &&
                Objects.equals(_hash, block._hash) &&
                Objects.equals(previousHash, block.previousHash) &&
                Objects.equals(_name, block._name) &&
                Objects.equals(_class, block._class) &&
                Objects.equals(number, block.number) &&
                Objects.equals(C4, block.C4) &&
                Objects.equals(sk, block.sk) &&
                Objects.equals(pk, block.pk);
    }

    @Override
    public int hashCode() {
        return Objects.hash(_index, _hash, previousHash, _timestamp, _name, _class, number, C4, sk, pk);
    }
}
